<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul,
        ol,
        li {
            list-style: none;
        }

        .box {
            width: 600px;
            height: 400px;
            border: 10px solid pink;
            margin: 30px auto;
            display: flex;
            flex-direction: column;
        }

        ul {
            width: 100%;
            height: 50px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        ul>li {
            flex: 1;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #fff;
            background-color: skyblue;
            font-size: 30px;
        }

        ul>li.active {
            background-color: orange;
        }

        ol {
            flex: 1;
            position: relative;
            width: 100%;
        }

        ol>li {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            background-color: #ccc;
            color: #fff;
            font-size: 100px;

            display: none;
            justify-content: center;
            align-items: center;
        }

        ol>li.active {
            display: flex;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li class="active">0</li>
            <li>1</li>
            <li>2</li>
        </ul>
        <ol>
            <li class="active">0</li>
            <li>1</li>
            <li>2</li>
        </ol>
    </div>
    <script src="../js/tabbox.js"></script>
    <script>
        const box = document.querySelector(".box");
        // const btns = box.querySelectorAll("ul>li");
        // const contents = box.querySelectorAll("ol>li");

        //给所有按钮添加监听
        // for (let i = 0; i < btns.length; i++) {
        //    btns[i].setAttribute("index",i);
        // //    console.log(i);

        //    btns[i].onclick =function(e){
        //        //找出这是第几个btn
        //        let index = this.getAttribute("index");

        //        contents.forEach((item,i)=>{
        //            item.classList.remove("active");
        //            btns[i].classList.remove("active");
        //        });

        //        //给当前按钮设置active
        //        this.classList.add("active");

        //        contents[index].classList.add("active");
        //    }
            
        // }

        const tabBox = new TabBox(box);
    </script>
</body>

</html>